<template>
	<view>
		<view class="img">
			<image class="imgp" style="" :src="src"></image>
			<text class="title">儒雅牛</text>
		</view>
		<view class="list">
			<span>当前版本:</span>
			<span>{{version}}</span>
		</view>
		<view class="list" style="display: block;padding: 0 20upx;">
			<button @click="appversioncheck" style="color:#fff;background-color:#FFBE53;" type="default">检查更新</button>
		</view>
		<view class="bottom">
			<span @click="goxieyi()" class="left">《儒雅牛用户服务协议》</span>
			<span @click="goyinsi()" class="right">《儒雅牛用户隐私协议》</span>
		</view>
	</view>
</template>

<script>
	import {
		appversioncheck
	} from '@/api/home'
	export default {
		data() {
			return {
				version: uni.version,
				src: '../../static/logo.png'
			}
		},
		created() {},
		methods: {
			goyinsi() {
				uni.navigateTo({
					url: '../login/yinsi'
				})
			},
			goxieyi () {
				uni.navigateTo({
					url: '../login/xieyi'
				})
			},
			appversioncheck() {
				let this_ = this;
				appversioncheck({
					type: 0,
					version: uni.version
				}).then(res => {
					if (res.success == 1) {
						if (res.data != null) {
							// if (res.data.isConstraint == 0) {
							uni.showModal({
								title: '提示',
								content: '发现新版本' + res.data.version + '！',
								showCancel: true,
								success: function(ress) {
									if (ress.confirm) {
										plus.runtime.openURL(res.data.fullPath, function(res) {

										});
									} else if (res.cancel) {
										console.log('用户点击取消');
									}
								}
							});
							// } else {
							// 	// plus.runtime.quit()
							// 	// plus.runtime.openURL(res.data.fullPath, function(res) {

							// 	// })
							// }
						} else {
							uni.showModal({
								title: '提示',
								content: '已是最新版本！',
								showCancel: false,
								success: function(ress) {
									if (ress.confirm) {
										plus.runtime.openURL(res.data.fullPath, function(res) {

										});
									} else if (res.cancel) {
										console.log('用户点击取消');
									}
								}
							});
						}
					}
				})
			},
		}
	}
</script>

<style>
	page {
		background-color: #fff;
		height: 100vh;
	}

	.img {
		position: relative;
		width: 100%;
		height: 200rpx;
		top: 200rpx;
	}

	.imgp {
		position: absolute;
		margin: 0 auto;
		left: 0;
		right: 0;
		width: 160rpx;
		height: 160rpx;
	}

	.title {
		position: absolute;
		margin: 0 auto;
		left: 0;
		right: 0;
		text-align: center;
		top: 180rpx;
	}

	.list {
		position: relative;
		top: 200rpx;
		margin: 80rpx auto;
		display: flex;
		flex-direction: row;
		justify-content: center;
	}

	.bottom {
		position: relative;
		height: 60rpx;
		margin-top: 80%;
		color: #1467FF;
		font-size: 30rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.left {
		margin-bottom: 20rpx;
	}

	/* .right {
		position: absolute;
		font-size: 30rpx;
		right: 15%;
	} */
</style>
